import { domainService } from '~/config/server';
import { NetService } from '~/utils/net.service';
import { Inject } from '~/core/decorator';
import { FilterService } from '~/utils/filter.service';

export class CaseAssistService {
  @Inject(NetService)
  private netService: NetService;

  /**
   * 获取协催管理-外访待分配-数据显示
   */
  public getAllWaitVisitCaseAssist(data, page, sort) {
    return this.netService.send({
      server: domainService.caseAssistController.getAllWaitVisitCaseAssist,
      data: {
        caseNumber: data.caseNumber,
        batchNumber: data.batchNumber,
        principalId: data.principalId,
        personalName: data.personalName,
        idCard: data.idCard,
        loanDateMin: FilterService.dateRanageFormat(data.loanDate).start,
        loanDateMax: FilterService.dateRanageFormat(data.loanDate).end,
        mobileNo: data.mobileNo,
        partnerName: data.partnerName,
        bankName: data.bankName,
        mainDeptName: data.mainDeptName,
        currentCollectorRealName: data.currentCollectorRealName,
        loanAmountMin: data.loanAmount ? data.loanAmount.min : '',
        loanAmountMax: data.loanAmount ? data.loanAmount.max : '',
        loanPeriodMin: data.loanPeriod ? data.loanPeriod.min : '',
        loanPeriodMax: data.loanPeriod ? data.loanPeriod.max : '',
        overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : '',
        overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : '',
        businessAddress: data.businessAddress,
        boardAddress: data.boardAddress,
        plateNum: data.plateNum,
        collectionType: data.collectionType,
        flowInTimeMin: FilterService.dateRanageFormat(data.flowInTime).start,
        flowInTimeMax: FilterService.dateRanageFormat(data.flowInTime).end,
        personalCollectionRemainingDaysMin: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.min : '',
        personalCollectionRemainingDaysMax: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.max : '',
      },
      page,
      sort,
    });
  }

  /**
   * 获取协催管理-电催待分配-数据显示
   */
  public getAllWaitTelCaseAssist(data, page, sort) {
    return this.netService.send({
      server: domainService.caseAssistController.getAllWaitTelCaseAssist,
      data: {
        caseNumber: data.caseNumber,
        batchNumber: data.batchNumber,
        principalId: data.principalId,
        personalName: data.personalName,
        idCard: data.idCard,
        loanDateMin: FilterService.dateRanageFormat(data.loanDate).start,
        loanDateMax: FilterService.dateRanageFormat(data.loanDate).end,
        mobileNo: data.mobileNo,
        partnerName: data.partnerName,
        bankName: data.bankName,
        mainDeptName: data.mainDeptName,
        currentCollectorRealName: data.currentCollectorRealName,
        loanAmountMin: data.loanAmount ? data.loanAmount.min : '',
        loanAmountMax: data.loanAmount ? data.loanAmount.max : '',
        loanPeriodMin: data.loanPeriod ? data.loanPeriod.min : '',
        loanPeriodMax: data.loanPeriod ? data.loanPeriod.max : '',
        overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : '',
        overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : '',
        businessAddress: data.businessAddress,
        boardAddress: data.boardAddress,
        plateNum: data.plateNum,
        collectionType: data.collectionType,
        flowInTimeMin: FilterService.dateRanageFormat(data.flowInTime).start,
        flowInTimeMax: FilterService.dateRanageFormat(data.flowInTime).end,
        personalCollectionRemainingDaysMin: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.min : '',
        personalCollectionRemainingDaysMax: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.max : '',
      },
      page,
      sort,
    });
  }

  /**
   * 获取协催管理-法务待分配-数据显示
   */
  public getAllWaitLegalCaseAssist(data, page, sort) {
    return this.netService.send({
      server: domainService.caseAssistController.getAllWaitLegalCaseAssist,
      data: {
        caseNumber: data.caseNumber,
        batchNumber: data.batchNumber,
        principalId: data.principalId,
        personalName: data.personalName,
        idCard: data.idCard,
        loanDateMin: FilterService.dateRanageFormat(data.loanDate).start,
        loanDateMax: FilterService.dateRanageFormat(data.loanDate).end,
        mobileNo: data.mobileNo,
        partnerName: data.partnerName,
        bankName: data.bankName,
        mainDeptName: data.mainDeptName,
        currentCollectorRealName: data.currentCollectorRealName,
        loanAmountMin: data.loanAmount ? data.loanAmount.min : '',
        loanAmountMax: data.loanAmount ? data.loanAmount.max : '',
        loanPeriodMin: data.loanPeriod ? data.loanPeriod.min : '',
        loanPeriodMax: data.loanPeriod ? data.loanPeriod.max : '',
        overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : '',
        overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : '',
        businessAddress: data.businessAddress,
        boardAddress: data.boardAddress,
        plateNum: data.plateNum,
        collectionType: data.collectionType,
        flowInTimeMin: FilterService.dateRanageFormat(data.flowInTime).start,
        flowInTimeMax: FilterService.dateRanageFormat(data.flowInTime).end,
        personalCollectionRemainingDaysMin: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.min : '',
        personalCollectionRemainingDaysMax: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.max : '',
      },
      page,
      sort,
    });
  }

  /**
   * 协催管理-外访催收-数据显示
   */
  public getAllVisitCaseAssist(data, page, sort) {
    return this.netService.send({
      server: domainService.caseAssistController.getAllVisitCaseAssist,
      data: {
        caseNumber: data.caseNumber,
        batchNumber: data.batchNumber,
        principalId: data.principalId,
        personalName: data.personalName,
        idCard: data.idCard,
        loanDateMin: FilterService.dateRanageFormat(data.loanDate).start,
        loanDateMax: FilterService.dateRanageFormat(data.loanDate).end,
        mobileNo: data.mobileNo,
        partnerName: data.partnerName,
        bankName: data.bankName,
        mainDeptName: data.mainDeptName,
        currentCollectorRealName: data.currentCollectorRealName,
        loanAmountMin: data.loanAmount ? data.loanAmount.min : '',
        loanAmountMax: data.loanAmount ? data.loanAmount.max : '',
        loanPeriodMin: data.loanPeriod ? data.loanPeriod.min : '',
        loanPeriodMax: data.loanPeriod ? data.loanPeriod.max : '',
        overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : '',
        overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : '',
        businessAddress: data.businessAddress,
        boardAddress: data.boardAddress,
        plateNum: data.plateNum,
        collectionType: data.collectionType,
        flowInTimeMin: FilterService.dateRanageFormat(data.flowInTime).start,
        flowInTimeMax: FilterService.dateRanageFormat(data.flowInTime).end,
        personalCollectionRemainingDaysMin: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.min : '',
        personalCollectionRemainingDaysMax: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.max : '',
        deptId: data.deptId ? (data.deptId.length === 0 ? '' : data.deptId[data.deptId.length - 1]) : '',
        assistCollectorName: data.assistCollectorName,
        flag: data.flag,
      },
      page,
      sort,
    });
  }
  /**
   * 协催管理-电催催收-数据显示
   */
  public getAllTelCaseAssist(data, page, sort) {
    return this.netService.send({
      server: domainService.caseAssistController.getAllTelCaseAssist,
      data: {
        caseNumber: data.caseNumber,
        batchNumber: data.batchNumber,
        principalId: data.principalId,
        personalName: data.personalName,
        idCard: data.idCard,
        loanDateMin: FilterService.dateRanageFormat(data.loanDate).start,
        loanDateMax: FilterService.dateRanageFormat(data.loanDate).end,
        mobileNo: data.mobileNo,
        partnerName: data.partnerName,
        bankName: data.bankName,
        mainDeptName: data.mainDeptName,
        currentCollectorRealName: data.currentCollectorRealName,
        loanAmountMin: data.loanAmount ? data.loanAmount.min : '',
        loanAmountMax: data.loanAmount ? data.loanAmount.max : '',
        loanPeriodMin: data.loanPeriod ? data.loanPeriod.min : '',
        loanPeriodMax: data.loanPeriod ? data.loanPeriod.max : '',
        overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : '',
        overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : '',
        businessAddress: data.businessAddress,
        boardAddress: data.boardAddress,
        plateNum: data.plateNum,
        collectionType: data.collectionType,
        flowInTimeMin: FilterService.dateRanageFormat(data.flowInTime).start,
        flowInTimeMax: FilterService.dateRanageFormat(data.flowInTime).end,
        personalCollectionRemainingDaysMin: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.min : '',
        personalCollectionRemainingDaysMax: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.max : '',
        deptId: data.deptId ? (data.deptId.length === 0 ? '' : data.deptId[data.deptId.length - 1]) : '',
        assistCollectorName: data.assistCollectorName,
        flag: data.flag,
      },
      page,
      sort,
    });
  }

  /**
   * 协催管理-法务催收-数据显示
   */
  public getAllLegalCaseAssist(data, page, sort) {
    return this.netService.send({
      server: domainService.caseAssistController.getAllLegalCaseAssist,
      data: {
        caseNumber: data.caseNumber,
        batchNumber: data.batchNumber,
        principalId: data.principalId,
        personalName: data.personalName,
        idCard: data.idCard,
        loanDateMin: FilterService.dateRanageFormat(data.loanDate).start,
        loanDateMax: FilterService.dateRanageFormat(data.loanDate).end,
        mobileNo: data.mobileNo,
        partnerName: data.partnerName,
        bankName: data.bankName,
        mainDeptName: data.mainDeptName,
        currentCollectorRealName: data.currentCollectorRealName,
        loanAmountMin: data.loanAmount ? data.loanAmount.min : '',
        loanAmountMax: data.loanAmount ? data.loanAmount.max : '',
        loanPeriodMin: data.loanPeriod ? data.loanPeriod.min : '',
        loanPeriodMax: data.loanPeriod ? data.loanPeriod.max : '',
        overdueAmountMin: data.overdueAmount ? data.overdueAmount.min : '',
        overdueAmountMax: data.overdueAmount ? data.overdueAmount.max : '',
        businessAddress: data.businessAddress,
        boardAddress: data.boardAddress,
        plateNum: data.plateNum,
        collectionType: data.collectionType,
        flowInTimeMin: FilterService.dateRanageFormat(data.flowInTime).start,
        flowInTimeMax: FilterService.dateRanageFormat(data.flowInTime).end,
        personalCollectionRemainingDaysMin: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.min : '',
        personalCollectionRemainingDaysMax: data.personalCollectionRemainingDays ? data.personalCollectionRemainingDays.max : '',
        deptId: data.deptId ? (data.deptId.length === 0 ? '' : data.deptId[data.deptId.length - 1]) : '',
        assistCollectorName: data.assistCollectorName,
        flag: data.flag,
      },
      page,
      sort,
    });
  }

  /**
   * 协催管理-外访待分配-分案
   */
  public confirmDistributeCase(data) {
    return this.netService.send({
      server: domainService.caseAssistController.distributeCaseAssist,
      data,
    });
  }

  /**
   * 协催管理-案件标色
   */
  public markCaseAssistColor(data) {
    return this.netService.send({
      server: domainService.caseAssistController.markCaseAssistColor,
      data,
    });
  }
}
